{include file="../template/header.html" /}

<div class="my-3 my-md-5">
    <div class="container">
        <div class="row">
            <div class="col-lg-8 mx-auto">
                <form class="card" method="POST" enctype="multipart/form-data">
                    <div class="card-body">
                        <h3 class="card-title">预约就诊</h3>
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label">姓名</label>
                                    <input type="text" class="form-control" name="name" value="{$a['name']}" required>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label">医生</label>
                                    <select class="form-control" name="doctor">
                                        <option value="{$Think.session.uid}">{$Think.session.name}</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label">照片</label>
                                    <input type="file" accept="image/gif,image/jpeg,image/png" class="form-control" name="photo" required>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label">性别</label>
                                    <div class="custom-controls-stacked">
                                        <label class="custom-control custom-radio custom-control-inline">
                                            <input type="radio" class="custom-control-input" name="gender" value="male"
                                                checked required>
                                            <span class="custom-control-label">男</span>
                                        </label>
                                        <label class="custom-control custom-radio custom-control-inline">
                                            <input type="radio" class="custom-control-input" name="gender"
                                                value="female" required>
                                            <span class="custom-control-label">女</span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label">就诊日期</label>
                                    <input type="date" id="firstdate" class="form-control" name="firstdate" value="{$a['time']}" required>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label">电话</label>
                                    <input type="number" class="form-control" name="tel" value="{$a['tel']}" required>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label">是否添加病例？</label>
                                    <div class="custom-controls-stacked">
                                        <label class="custom-control custom-radio custom-control-inline">
                                            <input type="radio" class="custom-control-input" name="needcase"
                                                value="true" required>
                                            <span class="custom-control-label">现在添加</span>
                                        </label>
                                        <label class="custom-control custom-radio custom-control-inline">
                                            <input type="radio" class="custom-control-input" name="needcase"
                                                value="false" readonly>
                                            <span class="custom-control-label">稍后上传</span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-8">
                                <div class="form-group">
                                    <label class="form-label">住址</label>
                                    <input type="text" class="form-control" name="address" required>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label">积分</label>
                                    <input type="number" class="form-control" name="points" required>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="card-body" id="case" style="display: none">
                        <h3 class="card-title">添加病例</h3>
                        <div class="row">
                        	<div class="col-md-12">
                                <div class="form-group">
                                    <label class="form-label">客户诉求</label>
                                    <textarea class="form-control" id="ask" name="ask">{$a['ask']}</textarea>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="form-label">病例内容</label>
                                    <div id="editor"></div>
                                    <textarea class="form-control" id="content" name="casecontent" style="display: none"></textarea>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <div class="form-group">
                                    <label class="form-label">开具处方</label>
                                    <textarea class="form-control" id="prescription" name="prescription"></textarea>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label">是否需要复诊</label>
                                    <div class="custom-controls-stacked">
                                        <label class="custom-control custom-radio custom-control-inline">
                                            <input type="radio" class="custom-control-input" name="needrevisit"
                                                value="true">
                                            <span class="custom-control-label">是</span>
                                        </label>
                                        <label class="custom-control custom-radio custom-control-inline">
                                            <input type="radio" class="custom-control-input" name="needrevisit"
                                                value="false">
                                            <span class="custom-control-label">否</span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-8" id="revisit" style="display: none">
                                <div class="form-group">
                                    <label class="form-label">复诊日期</label>
                                    <input type="date" name="revisitdate" id="revisitdate"  class="form-control">
                                </div>
                            </div>
                        </div>

                    </div>

                    <div class="card-footer text-right">
                        <button type="submit" class="btn btn-primary" name="AddCustomer">添加</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    require(['__JS__/wangEditor.min.js'], function (E) {
    var editor = new E('#editor')
    editor.customConfig.onchange = function (html) {
            // 监控变化，同步更新到 textarea
            $("#content").val(html)
        }
    editor.customConfig.menus = [
    'head',  // 标题
    'bold',  // 粗体
    'fontSize',  // 字号
    'italic',  // 斜体
    'underline',  // 下划线
    'foreColor',  // 文字颜色
    'justify',  // 对齐方式
    'image',  // 插入图片
    ]
    editor.customConfig.uploadImgServer = '/Customer/CaseImgUpload'
    editor.customConfig.uploadImgMaxLength = 1
    editor.customConfig.uploadFileName = 'caseImg'
    editor.customConfig.debug = location.href.indexOf('wangeditor_debug_mode=1') > 0
    editor.create()
    })
    var now = new Date();
    var day = ("0" + now.getDate()).slice(-2);
    var month = ("0" + (now.getMonth() + 1)).slice(-2);
    var today = now.getFullYear() + "-" + (month) + "-" + (day);
    $('#firstdate').val(today);
    $("input[name='needcase']").change(function () {
        if (this.value == 'true') {
            $("#case").show();
        }
        else if (this.value == 'false') {
            $("#case").hide();
        }
    });
    $("input[name='needrevisit']").change(function () {
        if (this.value == 'true') {
            $("#revisit").show();
        }
        else if (this.value == 'false') {
            $("#revisit").hide();
        }
    });
</script>
{include file="../template/footer.html" /}